package Servlets;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modelo.Ofertas;
import modelo.listaOfertas;

/**
 * Servlet implementation class servletListarO
 */
@WebServlet("/servletListarO")
public class servletListarOfertas extends HttpServlet implements Servlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public servletListarOfertas() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//String criterio = request.getParameter("sorting[0][order]");
		// cadena = "";
		ArrayList<Ofertas> lista = new ArrayList<Ofertas>();
		listaOfertas lista2 = new listaOfertas();
		lista = lista2.listaO();
		response.getWriter().write("<table class='table'>");
		for(Ofertas d:lista) {
			response.getWriter().write("<tr><td>" + d.getIdOfertas()+ "</td><td>" +d.getNombre()+ "</td><td>" +d.getDescripcion()+ "</td><td>" +d.getDescuentoPorcentual()+ "</td><td>" +d.getFechaCaducidad()+ "</td><td>" +d.getUbicacion()+"<td></tr>");
	        }//hola
		response.getWriter().write("<table>");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
